/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.florent37.materialtextfield.sample;

import com.github.florent37.materialtextfield.MaterialTextField;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;

/**
 * Main ability class
 */
public class MainAbility extends Ability {
    MaterialTextField materialTextField;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        materialTextField = (MaterialTextField) findComponentById(ResourceTable.Id_testfield);
        Button btnTest = (Button) findComponentById(ResourceTable.Id_btnTest);
        materialTextField.setBackgroundColor(Color.WHITE);
        btnTest.setClickedListener(
                (Component.ClickedListener)
                        component -> {
                            /**
                             * getBackgroundColo used to get the backgroud color
                             */
                            materialTextField.getBackgroundColor();
                            /**
                             * getCard is used to get instace of card layout.
                             */
                            materialTextField.getCard();
                            /**
                             * getImage is used to get the reference of image
                             */
                            materialTextField.getImage();
                            /**
                             * getLabel is used to get the lable text
                             */
                            materialTextField.getLabel();
                            /**
                             * getEditText is used to get the reference of TextFild.
                             */
                            materialTextField.getEditText();
                            /**
                             *  getEditTextLayout is used to get reference of the TextField layout instance.
                             */
                            materialTextField.getEditTextLayout();
                            /**
                             * isExpanded used to get TextFiled's Expand status.
                             */
                            materialTextField.isExpanded();
                        });
    }
}
